#!/usr/bin/perl -w

use strict;
use warnings;
use utf8;
use open ':encoding(utf8)';
use lib '../';
use ImportHelpers;

my $sourceDir = ImportHelpers::getSourceDirName(__FILE__);

ImportHelpers::insertWork(
	id        => 5,
	language  => 'grc',
	osis_id   => 'ByzMT',
	name      => "Byzantine/Majority Text (2000)",
	type      => 'manuscript-edition',
	copyright => "Edited by Maurice A. Robinson and William G. Pierpont. Similar to an earlier production of Hodges and Farstad in being based on von Soden's apparatus.",
	url       => ImportHelpers::getSourceExternalURL($sourceDir),
	licenses  => [qw( http://creativecommons.org/licenses/publicdomain/ )]
);


open IN, "$sourceDir/greek_byzantine_2000_parsed_utf8.txt"
	or die "Dir greek_byzantine_2000_parsed_utf8.txt doesn't exist.";

while(<IN>){
	#next if !/^62N\t/; #is 1 John
	next if not s/^(\d+\w)\t+(\d+)\t+(\d+)\t+\d+\t+//;
	
	my $book = $ImportHelpers::unboundNumToOsisCode{$1};
	next if !ImportHelpers::isBookOK($book);
	my $chapter = $2;
	my $verse = $3;
	
	s/\r//g;
	chomp;
	
	my @tokens = ImportHelpers::parseUnboundVerseLine($_);
	foreach my $token (@tokens){ #(split(/\r?\n/)){
		ImportHelpers::insertToken(
			data => $token->{data},
			type => $token->{type},
			
			book => $book,
			chapter => $chapter,
			verse => $verse,
			
			parsing => $token->{parse},
			strongs => join(';', @{$token->{strongs}})
		);
	}
}
ImportHelpers::finishBookRefs();
close IN;


1;